package com.bjsxt.service.imp;

import java.util.List;

import org.apache.commons.io.input.DemuxInputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bjsxt.commons.DataGridModel;
import com.bjsxt.mapper.ProviderMapper;
import com.bjsxt.pojo.Provider;
import com.bjsxt.pojo.ProviderExample;
import com.bjsxt.service.ProviderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sun.corba.se.impl.orbutil.concurrent.DebugMutex;

/**
 * @author 陈强
 */
@Service
public class ProviderServiceImpl implements ProviderService {

	@Autowired
	private ProviderMapper providerMapper;
	
	@Override
	public DataGridModel findProvider(Integer page,Integer rows) {
		PageHelper.startPage(page, rows);
		ProviderExample px=new ProviderExample();
		List<Provider> list=this.providerMapper.selectByExample(px);
		PageInfo<Provider> p=new PageInfo<>(list);
		Long total =p.getTotal();
		DataGridModel dgm=new DataGridModel();
		dgm.setRows(list);
		dgm.setTotal(total);
		return dgm;
	}

	@Override
	public void addProvider(Provider provider) {
		this.providerMapper.insertSelective(provider);
	}

	@Override
	public void dropProviderById(Integer providerid) {
		this.providerMapper.deleteByPrimaryKey(providerid);
	}

	@Override
	public void modifyProvider(Provider provider) {
		this.providerMapper.updateByPrimaryKey(provider);
	}
}
